<template>
  <div id="app">
    <transition :name="routerTransition">
      <keep-alive>
        <router-view />
      </keep-alive>
    </transition>
  </div>
</template>

<script>
import { setDocumentTitle } from '@/utils';

import Dsx from '@hips/plugin-dataset-vuex';

export default {
  name: 'App',
  data() {
    return {
      dsx: new Dsx({
        name: 'app',
      }),
      routerTransition: 'router-slide-left',
    };
  },
  watch: {
    $route(to, from) {
      setDocumentTitle(to.meta.title);

      this.routerTransition = from.meta.routerTransition;
    },
  },
  mounted() {
    const search = window.location.search;
    if (search !== '') {
      let t = search.split('?')[1].split('&');
      let searchObj = {};
      t.map((item) => {
        searchObj[item.split('=')[0]] = item.split('=')[1];
      });

      this.dsx.setState('locationSearch', searchObj);
    }
  },
};
</script>

<style lang="less">
@import 'style/theme.less';
</style>
